<template>
  地图类型：
  <el-select v-model="BMapSetting.type" @change="selectLineByInitMap" placeholder="请选择">
    <el-option value="BMAP_SATELLITE_MAP" label="卫星图"></el-option>
    <el-option value="BMAP_NORMAL_MAP" label="常规地图"></el-option>
  </el-select>
  <br/>
  <br/>

  <div style="height: 740px" ref="BMapRef" id="bMap"></div>
  <!-- 放大图片的对话框 -->
  <el-dialog  v-model="dataMap.dialogVisible" >
    <img width="100%" :src="dataMap.currentImage" alt="">
  </el-dialog>
</template>
<script setup lang="ts">
import {reactive, ref, onMounted, watch} from "vue";
import { ElMessageBox,ElMessage } from "element-plus";
import baseService from "@/service/baseService";
import {useRoute} from "vue-router";
import app from "@/constants/app";
import {getToken} from "@/utils/cache";
let dataMap = reactive({
  dialogVisible:false,
  currentImage:"" as string,
  showProject: true,
  showProjectTable: true,
  showLine: false,
  showEquipment: false,
  showLineTable: false,
  showEquipmentTable: false,
  projectData: {
    id: '',
    name: '',
    provinceName: '',
    provinceId: '',
    cityName: '',
    cityId: '',
    creaName: '',
    creaId: '',
    projectHead: '',
    projectMember: '',
    createDate: '',
    state: '',
    notes: '',
    equipmentCount: 0
  } as any,
  lineSelect: [] as any,
  equipmentCountData: [] as any,
  equipmentLineCountData: [] as any,
  equipmentDatAll:[] as any,
  line: "",
  lineOp:[] as any,
  lineId:[] as any,
  lineSelectMap:{} as any,
  lineData:{} as any,
  equipmentBMapClickId:"",
  equipmentBMapClickData:{}as any ,
  fileUrl:`${app.api}/sys/oss/downloadLocal`
})
onMounted(()=>{
  initMap();
})

let BMapSetting = reactive({
  lat: "116.404",
  lng: "39.915",
  type: "BMAP_SATELLITE_MAP",
})
//初始化地图
let BMapGL = window.BMap;
const initMap = () => {
  let map = new BMapGL.Map("bMap");
  map.centerAndZoom(new BMapGL.Point(BMapSetting.lat, BMapSetting.lng), 13);
  map.enableScrollWheelZoom(true);
  if ("BMAP_NORMAL_MAP" == BMapSetting.type) {
    map.setMapType(BMAP_NORMAL_MAP);
  } else if ("BMAP_SATELLITE_MAP" == BMapSetting.type) {
    map.setMapType(BMAP_SATELLITE_MAP);
  }
  map.addControl(new BMapGL.ScaleControl())

}
</script>
